package com.aaa.common.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Random;

/**
 * @Author: YuXin
 * @Date : Created in 2020/11/20 20:18
 * @ClassName : RandomUtil
 * @Description :
 * @Package_Name :
 */
public class RandomUtil {
    public static String randomCode() {
        DateFormat df = new SimpleDateFormat("yyyyMMddHHmm");
        Calendar calendar = Calendar.getInstance();
        String dateName = df.format(calendar.getTime());
        //实例化一个random的对象ne
        Random ne = new Random();
        //为变量赋随机值100-999
        int x = ne.nextInt(999 - 100 + 1) + 100;
        String randomOrder = String.valueOf(x);
        String random = dateName + randomOrder;
        return random;
    }
}
